package com.example.controller.courseController;

import com.example.pojo.coursePojo.CourseLog;
import com.example.pojo.shangPinDataPojo.ResultDate;
import com.example.service.courseService.CourseLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author:郭
 * @Description: TODO
 * @Date: 2022/12/8 10:37
 * @ClassName CourseLogController
 * 课程日志表
 */
@RequestMapping("/CourseLog")
@Controller
public class CourseLogController {
    @Autowired
    private CourseLogService courseLogService;
    /**
     * @Author: 郭
     * @Date: 2022/12/8 10:39
     * @Param:
     * @Return: ResultDate<CourseLog>
     * 根据对象全查日志表中的信息
     */
    @GetMapping("/getAll")
    @ResponseBody
    public ResultDate<CourseLog> getAll(){
        List<CourseLog> all = courseLogService.getAll();
        ResultDate<CourseLog> date = new ResultDate<>();
        date.setCount(courseLogService.getCount());
        date.setData(all);
        System.out.println("数据"+date);
        return date;
    }
    @ResponseBody
    @GetMapping("/insertCourseLog")
    public int insertCourseLog(CourseLog courseLog){
        return courseLogService.insertCourseLog(courseLog);
    }
}
